{{ partial "header.html" . }}

<div class="content container">
  <h1>Archives</h1>

  <p>Also see <a href="{{"/authors" | relLangURL}}">authors</a></p>

  {{ with .Site.GetPage "section" "posts" }}
    {{ range .Data.Pages.GroupByDate "2006" }}
    
    <section>
      <h2>{{ .Key }}</h2>
	  <div class="preview">
      <ul>
        {{ range .Pages }}
		  <p>
		  <aside> {{ .Date.Format "January 2" }}
			{{ if not (eq .Params.tags nil) }}
				{{ range .Params.tags }}
					<a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}/" style="text-decoration:none">#{{ lower . }}</a>
				{{ end }}
			{{ end }}
		  </aside>
          <a href="{{ .Permalink }}" class="permalink">{{ .Title }}</a>
          {{ partial "collab.html" . }}
		  </p>
        {{ end }}
      </ul>
	  </div>
    </section>
    {{ end }}
  {{ end }}
</div>

<section>
<h2 id="tags"> Tags </h2>

<!-- TODO: reverse index; list all posts per tag -->
<div class="tags">
<br>
{{$tags := newScratch }}
{{ range .Site.RegularPages }} 
{{ if eq .Type "posts"}}
	{{ range .Params.tags }}
		{{ $name := lower .  }}
		{{ $array := $tags.Get "tags" }} <!-- For some reason I can't directly add this code below -->
		{{ if not (in $array $name)}}
			{{ $tags.Add "tags" (slice $name)}}
			<a href="{{ "/tags/" | relLangURL }}{{ . | urlize }}/">{{ lower $name }}</a>
		{{ end }}
	{{end}}
{{ end }}
{{ end }}
</div>

</section>

{{ partial "footer.html" . }}
